import fse from 'fs-extra'
import path from 'path'

function addCesiumStaticFile() {
  const CESIUM_WORKERS_PATH = path.resolve(process.cwd(), 'node_modules/cesium/Build/Cesium/Workers')
  const CESIUM_THIRD_PARTY_PATH = path.resolve(process.cwd(), 'node_modules/cesium/Build/Cesium/ThirdParty')
  const CESIUM_ASSETS_PATH = path.resolve(process.cwd(), 'node_modules/cesium/Build/Cesium/Assets')
  const CESIUM_WIDGETS_PATH = path.resolve(process.cwd(), 'node_modules/cesium/Build/Cesium/Widgets')

  const CESIUM_PUBLIC_PATH = path.resolve(process.cwd(), 'public/cesium')

  console.log('🚀 清理Cesium旧版本静态资源...')
  fse.removeSync(CESIUM_PUBLIC_PATH)
  console.log('😄 清理Cesium旧版本静态资源完成!')

  console.log('🚀 添加Cesium-Workers静态资源...')
  fse.copySync(CESIUM_WORKERS_PATH, path.resolve(CESIUM_PUBLIC_PATH, 'Workers'))
  console.log('🚀 添加Cesium-ThirdParty静态资源...')
  fse.copySync(CESIUM_THIRD_PARTY_PATH, path.resolve(CESIUM_PUBLIC_PATH, 'ThirdParty'))
  console.log('🚀 添加Cesium-Assets静态资源...')
  fse.copySync(CESIUM_ASSETS_PATH, path.resolve(CESIUM_PUBLIC_PATH, 'Assets'))
  console.log('🚀 添加Cesium-Widgets静态资源...')
  fse.copySync(CESIUM_WIDGETS_PATH, path.resolve(CESIUM_PUBLIC_PATH, 'Widgets'))
  console.log('😄 添加Cesium静态资源完成!')
}

addCesiumStaticFile()
